Skip to content

Conversation

@Zalathar
Copy link
Member

Currently, thir::PatKind::Deref is used for ordinary &/&mut patterns, and also for &pin const and &pin mut patterns under feature(pin_ergonomics). The only way to distinguish between them is by inspecting the Ty attached to the pattern node.

That's non-obvious, making it easy to miss, and is also a bit confusing to read when it does occur.

This PR therefore adds an explicit pin: hir::Pinnedness field to thir::PatKind::Deref, to explicitly distinguish pin-deref nodes from ordinary builtin-deref nodes.

(I'm not deeply familiar with the future of pin-patterns, so I'm not sure whether that information is best carried as a field or as a separate PatKind, but I think this approach is at least an improvement over the status quo.)

r? Nadrieril (or compiler)

@Zalathar Zalathar added the F-pin_ergonomics `#![feature(pin_ergonomics)]` label Jan 18, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 18, 2026

Some changes occurred in match checking

cc @Nadrieril

Some changes occurred in exhaustiveness checking

cc @Nadrieril

Some changes occurred in match lowering

cc @Nadrieril

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 18, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 18, 2026

Nadrieril is not on the review rotation at the moment.
They may take a while to respond.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@Zalathar
Copy link
Member Author

I'll probably need to rebase this again after #151295.

@rust-bors

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 20, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Nadrieril
Copy link
Member

Big fan of this. The fact that this uncovered a bug is enough proof that we need this, if we needed any.

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 24, 2026

📌 Commit 566c23d has been approved by Nadrieril

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 24, 2026
rust-bors bot pushed a commit that referenced this pull request Jan 24, 2026
Rollup of 4 pull requests

Successful merges:

 - #149174 (`const` blocks as a `mod` item)
 - #151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`)
 - #151593 (miri subtree update)
 - #151516 (Do not emit errors on non-metaitem diagnostic attr input)

r? @ghost
@rust-bors rust-bors bot merged commit a7249d8 into rust-lang:main Jan 24, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 24, 2026
rust-timer added a commit that referenced this pull request Jan 24, 2026
Rollup merge of #151282 - Zalathar:pin-pat, r=Nadrieril

THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`

Currently, `thir::PatKind::Deref` is used for ordinary `&`/`&mut` patterns, and also for `&pin const` and `&pin mut` patterns under `feature(pin_ergonomics)`. The only way to distinguish between them is by inspecting the `Ty` attached to the pattern node.

That's non-obvious, making it easy to miss, and is also a bit confusing to read when it does occur.

This PR therefore adds an explicit `pin: hir::Pinnedness` field to `thir::PatKind::Deref`, to explicitly distinguish pin-deref nodes from ordinary builtin-deref nodes.

(I'm not deeply familiar with the future of pin-patterns, so I'm not sure whether that information is best carried as a field or as a separate `PatKind`, but I think this approach is at least an improvement over the status quo.)

r? Nadrieril (or compiler)
@Zalathar Zalathar deleted the pin-pat branch January 25, 2026 01:24
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 25, 2026
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#149174 (`const` blocks as a `mod` item)
 - rust-lang/rust#151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`)
 - rust-lang/rust#151593 (miri subtree update)
 - rust-lang/rust#151516 (Do not emit errors on non-metaitem diagnostic attr input)

r? @ghost
vinDelphini pushed a commit to vinDelphini/rust that referenced this pull request Jan 25, 2026
…iaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang#149174 (`const` blocks as a `mod` item)
 - rust-lang#151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`)
 - rust-lang#151593 (miri subtree update)
 - rust-lang#151516 (Do not emit errors on non-metaitem diagnostic attr input)

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-pin_ergonomics `#![feature(pin_ergonomics)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants